home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / amigaoscd / amigapluscd / AP-Website / forum / wbboard / pms.php < prev    next >
PHP Script  |  2001-11-16  |  17KB  |  360 lines

  1. <?
  2. require("_functions.php");
  3. require("_header.php");
  4. require("_board_jump.php");
  5.  
  6. if($user_id && $pms && $userdata[canusepms]) {
  7. if(!$box) $box = "inbox";
  8. if($action == "send" || $action == "new" || $action == "reply" || $action == "forward") {
  9.  
  10.     if($action == "send" && !$preview) {
  11.         $userid = getUserid($recipient);
  12.         $count_pm = $db_zugriff->query_first("SELECT COUNT(pmid) FROM bb".$n."_pms WHERE recipientid = '$userid'");
  13.         if(!$userid || $userid == $user_id || check_userobject($userid,$user_id,"ignorelist")) eval ("\$error = \"".gettemplate("pm_error1")."\";");
  14.         elseif($count_pm[0] >= $maxpms) eval("\$error = \"".gettemplate("pm_error2")."\";");
  15.         else {
  16.             $subject = editPostdata($subject);
  17.                     $message = nt_wordwrap($message);
  18.                     if($parseurl) $message = parseURL($message);
  19.             $message = editPostdata($message);
  20.             $db_zugriff->query("INSERT INTO bb".$n."_pms (senderid,recipientid,sendtime,subject,message,icon,disable_smilies,signature)VALUES ('$user_id','$userid','".time()."','$subject','$message','$posticon','$disablesmilies','$signature')");       
  21.                     if($copy) {
  22.                         $nr = $db_zugriff->insert_id();
  23.                         $db_zugriff->query("INSERT INTO bb".$n."_pmsend VALUES ('$user_id','$userid','$nr','','".time()."','$subject','$message','$posticon','$disablesmilies','$signature')");
  24.                     }
  25.                     if($replyid) $db_zugriff->query("UPDATE bb".$n."_pms SET reply = 1 WHERE pmid = '$replyid'");
  26.                     if($forwardid) $db_zugriff->query("UPDATE bb".$n."_pms SET forward = 1 WHERE pmid = '$forwardid'");
  27.                     header("LOCATION: pms.php?box=inbox$session");
  28.                 }        
  29.     }
  30.     if($action == "reply") {
  31.         $pmdata = $db_zugriff->query_first("SELECT * FROM bb".$n."_pms WHERE pmid = '$pmid' AND recipientid = '$user_id'");
  32.         $subject = prepare_topic($pmdata[subject]);
  33.         $message = prepare_quote($pmdata[message]);
  34.         $sendername = $recipient = getUsername($pmdata[senderid]);
  35.         $sendtime = formatdate($pmdata[sendtime],$longdateformat,0);
  36.         eval ("\$message = \"".gettemplate("pm_reply_message")."\";");
  37.         eval ("\$subject = \"".gettemplate("pm_reply_subject")."\";");
  38.         $replyid = $pmid;
  39.     }
  40.     if($action == "forward") {
  41.         $pmdata = $db_zugriff->query_first("SELECT * FROM bb".$n."_pms WHERE pmid = '$pmid' AND recipientid = '$user_id'");
  42.         $subject = prepare_topic($pmdata[subject]);
  43.         $message = prepare_quote($pmdata[message]);
  44.         $sendername = getUsername($pmdata[senderid]);
  45.         $sendtime = formatdate($pmdata[sendtime],$longdateformat,0);
  46.         eval ("\$message = \"".gettemplate("pm_forward_message")."\";");
  47.         eval ("\$subject = \"".gettemplate("pm_forward_subject")."\";");
  48.         $forwardid = $pmid;
  49.     }
  50.     if($userid) $recipient = getUsername($userid);
  51.             
  52.     if($ch_parseurl) $checked[0] = "CHECKED";
  53.     if($ch_disablesmilies) $checked[2] = "CHECKED";
  54.     if($ch_signature) $checked[3] = "CHECKED";
  55.     
  56.     if($preview) {
  57.         $subject = prepare_topic($subject);
  58.                         $user_info = $db_zugriff->query_first("SELECT signatur FROM bb".$n."_user_table WHERE username='$user_name'");
  59.                         if($user_info[signatur] && $signature && !$hide_signature) {
  60.                             $signatur = editPost($user_info[signatur],$disablesmilies);
  61.                 eval ("\$pre_signature = \"".gettemplate("thread_signature")."\";");
  62.             }
  63.                         if($posticon) $pre_posticon = "<img src=\"".$posticon."\">";
  64.                         else $pre_posticon = " ";
  65.                         $post = editPost($message,$disablesmilies);
  66.                         $message = stripslashes($message);             
  67.                         eval ("\$preview = \"".gettemplate("preview")."\";");
  68.                         
  69.                         if($parseurl) $checked[0] = "CHECKED";
  70.             else $checked[0] = "";
  71.             if($copy) $checked[1] = "CHECKED";
  72.             else $checked[1] = "";
  73.             if($disablesmilies) $checked[2] = "CHECKED";
  74.             else $checked[2] = "";
  75.             if($signature) $checked[3] = "CHECKED";
  76.             else $checked[3] = "";
  77.         }
  78.     
  79.     if($bbcode && $u_bbcode) $bbcode_buttons = getcodebuttons();
  80.     if($smilies && $u_bbcode) $bbcode_smilies = getclickysmilies(3,$anzahl_smilies);
  81.     if($html) eval ("\$note .= \"".gettemplate("newthread_html_enable")."\";");
  82.     else eval ("\$note .= \"".gettemplate("newthread_html_disable")."\";");
  83.     if(!$smilies) eval ("\$note .= \"".gettemplate("newthread_smilies_disable")."\";");
  84.     if(!$bbcode) eval ("\$note .= \"".gettemplate("newthread_bbcode_disable")."\";");
  85.     include("templates/posticons.php");
  86.     for($i = 0; $i < count($posticons); $i++) {
  87.         if(is_int($i/6) && $i) $choice_posticons .= "<br>";
  88.         elseif($i) $choice_posticons .= "    ";
  89.         $choice_posticons .= "<INPUT type=\"radio\" name=\"posticon\" value=\"$posticons[$i]\"";
  90.         if($posticon == $posticons[$i]) $choice_posticons .= " CHECKED";
  91.         $choice_posticons .= ">  <img src=\"$posticons[$i]\">";
  92.     }
  93.     if(!$posticon) $noicon[0] = "CHECKED"; 
  94.     if($session) $session_post = "<INPUT TYPE=\"HIDDEN\" NAME=\"sid\" VALUE=\"$sid\">";
  95.     
  96.     eval("dooutput(\"".gettemplate("pm_new")."\");");
  97.     exit;
  98. }
  99. if($action == "print") {
  100.  
  101.     $row = $db_zugriff->query_first("SELECT * FROM bb".$n."_pms WHERE pmid = '$pmid' AND recipientid = '$user_id'");
  102.     if(!$row[pmid]) {
  103.         header("LOCATION: misc.php?action=access_error&boardid=$boardid&styleid=$styleid$session");
  104.         exit;
  105.     }
  106.     
  107.     $user_info = $db_zugriff->query_first("SELECT username, signatur FROM bb".$n."_user_table WHERE userid = '$row[senderid]'");
  108.     $sendername = $user_info[username];
  109.     $subject = prepare_topic($row[subject]);
  110.     $message = editPost($row[message],$row[disable_smilies]);
  111.     if($user_info[signatur] && $row[signature] && !$hide_signature) {
  112.         $signatur = editSignatur($user_info[signatur],$row[disable_smilies]);
  113.         eval ("\$signature = \"".gettemplate("thread_signature")."\";");
  114.     }
  115.     $sendtime = formatdate($row[sendtime],$longdateformat,0);
  116.     
  117.     eval("dooutput(\"".gettemplate("pm_print")."\");");
  118.     exit;
  119. }
  120. if($action == "download") {
  121.     
  122.     $row = $db_zugriff->query_first("SELECT * FROM bb".$n."_pms WHERE pmid = '$pmid' AND recipientid = '$user_id'");
  123.     if(!$row[pmid]) {
  124.         header("LOCATION: misc.php?action=access_error&boardid=$boardid&styleid=$styleid$session");
  125.         exit;
  126.     }
  127.  
  128.     $user_info = $db_zugriff->query_first("SELECT username, signatur FROM bb".$n."_user_table WHERE userid = '$row[senderid]'");
  129.     $sendername = $user_info[username];
  130.     $subject = prepare_topic($row[subject]);
  131.     $message = prepare_topic($row[message]);
  132.     if($user_info[signatur] && $row[signature] && !$hide_signature) {
  133.         $signatur = prepare_topic($user_info[signatur]);
  134.         eval ("\$signature = \"".gettemplate("thread_signature")."\";");
  135.     }
  136.     $sendtime = formatdate($row[sendtime],$longdateformat,0);
  137.     
  138.     header("Content-disposition: filename=message-".$pmid.".txt"); 
  139.     header("Content-type: application/octet-stream"); 
  140.     header("Pragma: no-cache"); 
  141.     header("Expires: 0"); 
  142.     
  143.     eval("dooutput(\"".gettemplate("pm_download")."\");");
  144.     exit;
  145. }
  146. if($action == "delete") {
  147.  
  148.     $check = $db_zugriff->query_first("SELECT pmid FROM bb".$n."_pms WHERE pmid = '$pmid' AND recipientid = '$user_id'");
  149.     if(!$check[pmid]) {
  150.         header("LOCATION: misc.php?action=access_error&boardid=$boardid&styleid=$styleid$session");
  151.         exit;
  152.     }
  153.     if(!$save) eval("dooutput(\"".gettemplate("pm_delete_check")."\");");
  154.     else {
  155.         $db_zugriff->query("DELETE FROM bb".$n."_pms WHERE pmid = '$pmid'");
  156.         header("LOCATION: pms.php?boardid=$boardid&styleid=$styleid$session");
  157.     }    
  158.     exit;
  159. }
  160. if($action == "massdel") {
  161.  
  162.     unset($where);
  163.     for($i = 0; $i < count($select); $i++) {
  164.         if($where) $where .= " OR ";
  165.         $where .= "pmid='".$select[$i]."'";    
  166.     }
  167.     if($where) $db_zugriff->query("DELETE FROM bb".$n."_pms WHERE $where");
  168.     header("LOCATION: pms.php$session2");    
  169.     exit;
  170. }
  171.  
  172. if(substr($action, 0 , 2) == "->") {
  173.     
  174.     $folderid = substr($action, 2);
  175.     unset($where);
  176.     for($i = 0; $i < count($select); $i++) {
  177.         if($where) $where .= " OR ";
  178.         $where .= "pmid='".$select[$i]."'";    
  179.     }
  180.     if($where) $db_zugriff->query("UPDATE bb".$n."_pms SET folderid = '$folderid' WHERE $where");
  181.     header("LOCATION: pms.php?box=$folderid$session");    
  182.     exit;
  183. }
  184.  
  185. if($action == "massdel_send") {
  186.     unset($where);
  187.     for($i = 0; $i < count($select); $i++) {
  188.         if($where) $where .= " OR ";
  189.         $where .= "pmid='".$select[$i]."'";    
  190.     }
  191.     if($where) $db_zugriff->query("DELETE FROM bb".$n."_pmsend WHERE $where");
  192.     header("LOCATION: pms.php?box=outbox$session");    
  193.     exit;
  194. }
  195.  
  196. if($action == "createfolder" && $foldername = trim($foldername)) {
  197.     $check = $db_zugriff->query_first("SELECT folderid FROM bb".$n."_folders WHERE userid = '$user_id' AND foldername = '".editPostdata($foldername)."'");
  198.     $count = $db_zugriff->query_first("SELECT COUNT(folderid) FROM bb".$n."_folders WHERE userid = '$user_id'");
  199.     if($check[0] || $count[0] >= $maxfolder) {
  200.         eval ("\$output = \"".gettemplate("error28")."\";");
  201.         eval("dooutput(\"".gettemplate("action_error")."\");");
  202.         exit;
  203.     }
  204.     $db_zugriff->query("INSERT INTO bb".$n."_folders VALUES ('','$user_id','".editPostdata($foldername)."')");
  205.     header("LOCATION: pms.php?box=".$db_zugriff->insert_id()."$session");    
  206.     exit;
  207. }
  208.  
  209. if($action == "delfolder" && $folderid) {
  210.     $check = $db_zugriff->query_first("SELECT folderid FROM bb".$n."_folders WHERE userid = '$user_id' AND folderid = '$folderid'");
  211.     if($check[0]) {
  212.         $db_zugriff->query("UPDATE bb".$n."_pms SET folderid = 0 WHERE folderid = '$folderid'");
  213.         $db_zugriff->query("DELETE FROM bb".$n."_folders WHERE folderid = '$folderid'");
  214.         header("LOCATION: pms.php?box=inbox$session");    
  215.         exit;
  216.     }
  217.     exit;
  218. }
  219.  
  220. if($box == "inbox" && !$pmid) { 
  221.  
  222.     $result = $db_zugriff->query("SELECT bb".$n."_pms.*, bb".$n."_user_table.username AS sendername FROM bb".$n."_pms LEFT JOIN bb".$n."_user_table ON (bb".$n."_pms.senderid=bb".$n."_user_table.userid) WHERE recipientid = '$user_id' AND folderid = 0 ORDER BY sendtime DESC");
  223.     while ($row = $db_zugriff->fetch_array($result)) {
  224.     
  225.         if($row[icon]) $icon = "<img src=\"$row[icon]\">";
  226.         else $icon = " ";
  227.         $subject = prepare_topic($row[subject]);
  228.         $sendername = $row[sendername];
  229.         $sendtime = formatdate($row[sendtime],$longdateformat,1);
  230.         
  231.         if($row[sendtime] >= $old_time) $folder_image = "<img src=\"images/pmnew.gif\">";
  232.         elseif(!$row[view]) $folder_image = "<img src=\"images/pmunread.gif\">";
  233.         else {
  234.             if($row[reply] && $row[forward]) $folder_image = "<img src=\"images/pmreward.gif\">";
  235.             elseif($row[reply]) $folder_image = "<img src=\"images/pmreply.gif\">";
  236.             elseif($row[forward]) $folder_image = "<img src=\"images/pmforward.gif\">";
  237.             else  $folder_image = "<img src=\"images/pmnormal.gif\">";
  238.         }
  239.         
  240.         eval ("\$pm_pmbit .= \"".gettemplate("pm_pmbit")."\";");
  241.     }
  242.     $result = $db_zugriff->query("SELECT * FROM bb".$n."_folders WHERE userid = '$user_id' ORDER BY foldername ASC");
  243.     while($folder = $db_zugriff->fetch_array($result)) {
  244.         $folderdel_options .= "<option value=\"".$folder[folderid]."\">".editDBdata($folder[foldername])."</option>\n";
  245.         $change_options .= "<option value=\"".$folder[folderid]."\">".editDBdata($folder[foldername])."</option>\n";
  246.         $move_options .= "<option value=\"->".$folder[folderid]."\">Verschieben nach: ".editDBdata($folder[foldername])."</option>\n";
  247.     }
  248.     $foldername = "Inbox";
  249.     
  250.     if($folderdel_options) eval ("\$del_folder = \"".gettemplate("pm_delfolder")."\";");
  251.     if(!$pm_pmbit) eval ("\$pm_pmbit = \"".gettemplate("pm_nopm")."\";");
  252.     eval("dooutput(\"".gettemplate("pm_inbox")."\");");
  253. }
  254.  
  255. if($box != "inbox" && $box != "outbox" && !$pmid) {
  256.  
  257.     $result = $db_zugriff->query("
  258.                 SELECT bb".$n."_pms.*, username, foldername FROM bb".$n."_pms
  259.                 LEFT JOIN bb".$n."_user_table ON (bb".$n."_user_table.userid=bb".$n."_pms.senderid)
  260.                 LEFT JOIN bb".$n."_folders ON (bb".$n."_folders.folderid=bb".$n."_pms.folderid)
  261.                 WHERE recipientid = '$user_id' AND bb".$n."_pms.folderid = '$box' ORDER BY sendtime DESC");
  262.     while ($row = $db_zugriff->fetch_array($result)) {
  263.     
  264.         if($row[icon]) $icon = "<img src=\"$row[icon]\">";
  265.         else $icon = " ";
  266.         $subject = prepare_topic($row[subject]);
  267.         $sendername = $row[username];
  268.         $sendtime = formatdate($row[sendtime],$longdateformat,1);
  269.         
  270.         if($row[sendtime] >= $old_time) $folder_image = "<img src=\"images/pmnew.gif\">";
  271.         elseif(!$row[view]) $folder_image = "<img src=\"images/pmunread.gif\">";
  272.         else {
  273.             if($row[reply] && $row[forward]) $folder_image = "<img src=\"images/pmreward.gif\">";
  274.             elseif($row[reply]) $folder_image = "<img src=\"images/pmreply.gif\">";
  275.             elseif($row[forward]) $folder_image = "<img src=\"images/pmforward.gif\">";
  276.             else  $folder_image = "<img src=\"images/pmnormal.gif\">";
  277.         }
  278.         eval ("\$pm_pmbit .= \"".gettemplate("pm_pmbit")."\";");
  279.     }
  280.     $move_options .= "<option value=\"->inbox\">Verschieben nach: Inbox</option>\n";
  281.     $result = $db_zugriff->query("SELECT * FROM bb".$n."_folders WHERE userid = '$user_id' ORDER BY foldername ASC");
  282.     while($folder = $db_zugriff->fetch_array($result)) {
  283.         if($box==$folder[folderid]) $foldername = editDBdata($folder[foldername]);
  284.         $folderdel_options .= "<option value=\"".$folder[folderid]."\">".editDBdata($folder[foldername])."</option>\n";
  285.         $change_options .= "<option value=\"".$folder[folderid]."\">".editDBdata($folder[foldername])."</option>\n";
  286.         if($folder[folderid]!=$box)$move_options .= "<option value=\"->".$folder[folderid]."\">Verschieben nach: ".editDBdata($folder[foldername])."</option>\n";
  287.     }
  288.     if($folderdel_options) eval ("\$del_folder = \"".gettemplate("pm_delfolder")."\";");
  289.     if(!$pm_pmbit) eval ("\$pm_pmbit = \"".gettemplate("pm_nopm")."\";");
  290.     eval("dooutput(\"".gettemplate("pm_inbox")."\");");
  291. }
  292.  
  293. if($box == "outbox" && !$pmid) {
  294.  
  295.     $result = $db_zugriff->query("SELECT bb".$n."_pmsend.*, bb".$n."_user_table.username FROM bb".$n."_pmsend LEFT JOIN bb".$n."_user_table ON (bb".$n."_pmsend.recipientid=bb".$n."_user_table.userid) WHERE bb".$n."_pmsend.userid = '$user_id' ORDER BY sendtime DESC");
  296.     while ($row = $db_zugriff->fetch_array($result)) {
  297.         
  298.         if($row[icon]) $icon = "<img src=\"$row[icon]\">";
  299.         else $icon = " ";
  300.         $subject = prepare_topic($row[subject]);
  301.         $recipientname = $row[username];
  302.         $sendtime = formatdate($row[sendtime],$longdateformat,1);
  303.         $folder_image = "<img src=\"images/pmnormal.gif\">";
  304.         eval ("\$pm_pmbit .= \"".gettemplate("pm_pmbit2")."\";");
  305.     }
  306.     $result = $db_zugriff->query("SELECT * FROM bb".$n."_folders WHERE userid = '$user_id'");
  307.     while($folder = $db_zugriff->fetch_array($result)) $change_options .= "<option value=\"".$folder[folderid]."\">".editDBdata($folder[foldername])."</option>\n";
  308.     if(!$pm_pmbit) eval ("\$pm_pmbit = \"".gettemplate("pm_nopm")."\";");
  309.     eval("dooutput(\"".gettemplate("pm_outbox")."\");");
  310. }
  311.     if($pmid && $box != "outbox") {
  312.  
  313.         $row = $db_zugriff->query_first("SELECT * FROM bb".$n."_pms WHERE pmid = '$pmid'");
  314.         if($row[senderid]==$user_id) $links = " ";
  315.         elseif($row[recipientid]==$user_id) {
  316.             $db_zugriff->query("UPDATE bb".$n."_pms SET view=1 WHERE pmid = '$pmid'");
  317.             eval ("\$links = \"".gettemplate("pm_links")."\";");
  318.         }
  319.         else {
  320.             header("LOCATION: misc.php?action=access_error&boardid=$boardid&styleid=$styleid$session");
  321.             exit;
  322.         }
  323.         $user_info = $db_zugriff->query_first("SELECT username, signatur FROM bb".$n."_user_table WHERE userid = '$row[senderid]'");
  324.         $sendername = $user_info[username];
  325.         $recipientname = $db_zugriff->query_first("SELECT username FROM bb".$n."_user_table WHERE userid = '$row[recipientid]'");
  326.         $recipientname = $recipientname[username];
  327.         
  328.         if($row[icon]) $icon = "<img src=\"".$row[icon]."\">";
  329.         else $icon = " ";
  330.         $subject = prepare_topic($row[subject]);
  331.         $message = editPost($row[message],$row[disable_smilies]);
  332.         if($user_info[signatur] && $row[signature] && !$hide_signature) {
  333.             $signatur = editSignatur($user_info[signatur],$row[disable_smilies]);
  334.             eval ("\$signature = \"".gettemplate("thread_signature")."\";");
  335.         }
  336.         $sendtime = formatdate($row[sendtime],$longdateformat,0);
  337.             
  338.         eval("dooutput(\"".gettemplate("pm_view")."\");");
  339.     }
  340.     elseif($pmid) {
  341.     
  342.         $row = $db_zugriff->query_first("SELECT * FROM bb".$n."_pmsend WHERE pmid = '$pmid' AND userid = '$user_id'");
  343.         $sendername = $user_name;
  344.         $recipientname = getUsername($row[recipientid]);
  345.         
  346.         if($row[icon]) $icon = "<img src=\"".$row[icon]."\">";
  347.         else $icon = " ";
  348.         $subject = prepare_topic($row[subject]);
  349.         $message = editPost($row[message],$row[disable_smilies]);
  350.         if($user_info[signatur] && $row[signature] && !$hide_signature) {
  351.             $signatur = editSignatur($user_info[signatur],$row[disable_smilies]);
  352.             eval ("\$signature = \"".gettemplate("thread_signature")."\";");
  353.         }
  354.         $sendtime = formatdate($row[sendtime],$longdateformat,0);
  355.             
  356.         eval("dooutput(\"".gettemplate("pm_view")."\");");
  357.     }
  358. }
  359. else header("LOCATION: misc.php?action=access_error$session");
  360. ?>